@extends('admin.layouts')
@section('css')
    <link href="{{asset('assets/css/bootstrap.min.css')}}" rel="stylesheet" />
    <link rel="stylesheet" href="{{asset('assets/css/font-awesome.min.css')}}" />
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />

    <link rel="stylesheet" href="{{asset('assets/css/ace.min.css')}}" />
    <link rel="stylesheet" href="{{asset('assets/css/ace-rtl.min.css')}}" />
    <link rel="stylesheet" href="{{asset('assets/css/ace-skins.min.css')}}" />
    <script src="{{asset('assets/js/ace-extra.min.js')}}"></script>
    <link rel="stylesheet" type="text/css" href="{{asset('assets/uploadifive/uploadifive.css')}}">
@endsection
@section('content')

    <div class="main-content">
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
            </script>

            <ul class="breadcrumb">
                <li>
                    <i class="icon-home home-icon"></i>
                    <a href="{{url('admin/index')}}">首页</a>
                </li>
                <li class="active">收件箱</li>
            </ul><!-- .breadcrumb -->

            <div class="nav-search" id="nav-search">
                <form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
									<i class="icon-search nav-search-icon"></i>
								</span>
                </form>
            </div><!-- #nav-search -->
        </div>

        <div class="page-content">
            <div class="page-header">
                <h1>
                    收件箱
                </h1>
            </div><!-- /.page-header -->

            <div class="row">
                <div class="col-xs-12">
                    <!-- PAGE CONTENT BEGINS -->

                    <div class="row">
                        <div class="col-xs-12">
                            <div class="tabbable">

                                <div class="tab-content no-border no-padding">
                                    <div class="tab-pane in active">
                                        <div class="message-container">
                                            <div id="id-message-list-navbar" class="message-navbar align-center clearfix">
                                                <div class="message-bar">
                                                    <div class="message-infobar" id="id-message-infobar">
                                                        <span class="blue bigger-150">收件箱</span>
                                                        <span class="grey bigger-110">(<span id="jhfg">{{$counti}}</span>条未读)</span>
                                                    </div>

                                                    <div class="message-toolbar hide">
                                                        <a href="#" class="btn btn-xs btn-message">
                                                            <i class="icon-trash bigger-125"></i>
                                                            <span class="bigger-110">删除</span>
                                                        </a>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="message-list-container">
                                                <div class="message-list" id="message-list">
@foreach($questions as $qs)
                                                    <div class="message-item message-unread" id="gfdhfd{{$qs['id']}}">
																	<span class="sender" title="John Doe">
                                                                        @if(!empty($qs['username']))
																		{{$qs['username']}}
                                                                            @else
                                                                            游客
                                                                            @endif
																	</span>
                                                        <span class="attachment" onclick="deletess({{$qs['id']}})">
                                                            <i class="icon-trash bigger-120 red"></i>
														</span>
                                                        <span class="time" style="width: 140px">{{date('Y-m-d H:i:s',$qs['created_at'])}}</span>


																	<span class="summary">
                                                                        @if($qs['is_read']==1)
																		<span id="gfdhdfg" class="badge badge-info mail-tag"></span>
                                                                        @else
                                                                            <span id="gfdhdfg" class="badge badge-pink mail-tag"></span>
                                                                        @endif
																		<span class="text" onclick="showww({{$qs['id']}})">
                                                                            {{mb_substr($qs['question'],0,25,'utf-8')}}...
																		</span>
																	</span>
                                                    </div>
@endforeach
                                                </div>
                                            </div><!-- /.message-list-container -->

                                            <div class="message-footer clearfix">
                                                <div class="pull-left"> <span id="e346ter">{{$count}}</span>条消息 </div>
                                            </div>

                                            <div class="hide message-footer message-footer-style2 clearfix">
                                                <div class="pull-left"> simpler footer </div>

                                                <div class="pull-right">
                                                    <div class="inline middle"> message 1 of 151 </div>

                                                    &nbsp; &nbsp;
                                                    <ul class="pagination middle">
                                                        <li class="disabled">
																		<span>
																			<i class="icon-angle-left bigger-150"></i>
																		</span>
                                                        </li>

                                                        <li>
                                                            <a href="#">
                                                                <i class="icon-angle-right bigger-150"></i>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div><!-- /.message-container -->
                                    </div><!-- /.tab-pane -->

                                </div><!-- /.tab-content -->
                            </div><!-- /.tabbable -->
                        </div><!-- /.col -->
                    </div><!-- /.row -->
                    <!-- PAGE CONTENT ENDS -->
                </div><!-- /.col -->
            </div><!-- /.row -->
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="hfgjfgh" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabeldfh"></h4>
                </div>
                <div class="modal-body">
                    <span id="qusdgfgu"></span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
@endsection

@section('javascript')
    <script src='{{asset('assets/js/jquery-2.0.3.min.js')}}'></script>
    <script src="{{asset('assets/js/bootstrap.min.js')}}"></script>
    <script src="{{asset('assets/js/typeahead-bs2.min.js')}}"></script>
    <script src="{{asset('assets/js/bootstrap-wysiwyg.min.js')}}"></script>
    <!-- ace scripts -->
    <script type="text/javascript" src="{{asset('assets/layer/layer.js')}}"></script>
    <script src="{{asset('assets/js/ace-elements.min.js')}}"></script>
    <script src="{{asset('assets/js/ace.min.js')}}"></script>

    <script src="{{asset('assets/js/jquery.slimscroll.min.js')}}"></script>
    <script>
        function showww(id){
            $.post('',{'_token':'{{csrf_token()}}','id':id}, function (res) {
                $("#myModalLabeldfh").text(res[0].username);
                $("#qusdgfgu").text(res[0].question);
                $("#hfgjfgh").modal('show');
                if($("#jhfg").text()>0){
                    $("#jhfg").text(($("#jhfg").text()-1));
                }
                $("#gfdhdfg").removeClass('badge-pink').addClass('badge-info');
            });
        }

        function deletess(id){
            layer.confirm('你确定要删除？',{
                btn:['确定','取消']
            },function(i){
                layer.close(i);
                layer.load(1);
                $.post('{{url('admin/deletequestion')}}',{"_token":'{{csrf_token()}}','id':id},function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        $("#gfdhfd"+id).remove();
                        $("#e346ter").text(($("#e346ter").text()-1));
                        layer.msg(res.msg);
                    }else{
                        layer.msg(res.msg);
                    }
                });
            },function(){

            });
        }
    </script>
@endsection